﻿@model BMS.ViewModels.OrderModelList
@using System.Globalization

@{
    ViewBag.Title = "Quotations";
}

@section featured {
    <section class="featured">
        <div class="content-wrapper" align="center">
            <hgroup class="title">
                <h1>@ViewBag.Message</h1>
            </hgroup>
        </div>
    </section>
}

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <br align="center" />
    if (Model.orderList != null)
    {
        <table align="center" border="1" id="tblOrder">
            <tr class="tableHeader">
                <th width="150">Order Date</th>
                <th width="100">SO No</th>
                <th width="100">WO No</th>
                <th width="100">FM Name</th>
                <th width="250">Location</th>
                <th width="250">Description</th>
                <th width="200">Quotation No.</th>
                <th width="160">Actions</th>
            </tr>
            @foreach (var item in Model.orderList)
            {
                <tr>
                    <td align="center">@item.OrderCreationDate.ToString("yyyy-MMMM-dd", CultureInfo.CreateSpecificCulture("en-US"))</td>
                    <td align="center">@item.ServiceOrderNo</td>
                    <td align="center">@item.WorkOrderNo</td>
                    <td align="center">@item.FMName</td>
                    <td align="center">@item.Location</td>
                    <td align="center">@item.Description</td>
                    <td align="center">@item.QuotationNo</td>
                    @if (item.QuotationNo == "")
                    {
                        <td>
                            @Html.ActionLink("Add Quotation", "QuotCreator", "Quotation", new { soNo = item.ServiceOrderNo, fmName = item.FMName, quotNo = item.QuotationNo, orderDate = item.OrderCreationDate, location = item.Location, description = item.Description, isEdited = false }, new { @class = "openDialog2", data_dialog_id = "aboutlDialog2", data_dialog_title = "Create Quotation" })
                        </td>
                    }
                    else
                    {
                        <td>
                            @Html.ActionLink("Edit", "QuotCreator", "Quotation", new { soNo = item.ServiceOrderNo, fmName = item.FMName, quotNo = item.QuotationNo, orderDate = item.OrderCreationDate, location = item.Location, description = item.Description, isEdited = true }, new { @class = "openDialog2", data_dialog_id = "aboutlDialog2", data_dialog_title = "Edit Quotation" }) |
                            @Html.ActionLink("Details", "ViewQuotation", "Quotation", new { soNo = item.ServiceOrderNo, fmName = item.FMName, quotNo = item.QuotationNo }, new { @class = "openDialog2", data_dialog_id = "aboutlDialog2", data_dialog_title = "Quotation Detail" })
                        </td>
                    }
                </tr>
            }
        </table>
    }

    @*<div id="someDivId">This is some div</div>*@
}

<link href='~/Scripts/jquery-ui.css' rel='stylesheet'>
<script type="text/javascript" src="~/Scripts/jquery-2.1.0.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui.js"></script>
<link href='~/Scripts/filtergrid.css' rel='stylesheet'>
<script type="text/javascript" src="~/Scripts/tablefilter_all_min.js"></script>
<script type="text/javascript">
    $.ajaxSetup({ cache: false });

    $(document).ready(function () {
        var tf1_Props = {
            col_3: "select",
            col_4: "none",
            col_5: "none",
            col_7: "none",
            display_all_text: " [ Show all ] ",
            paging: true,
            sort_select: true,
            paging_length: 10,
            alternate_rows: true,
            rows_counter: true,
            rows_counter_text: "Rows:",
            btn_next_page_html: '<a href="javascript:;" style="margin:3px;">Next ></a>',
            btn_prev_page_html: '<a href="javascript:;" style="margin:3px;">< Previous</a>',
            btn_last_page_html: '<a href="javascript:;" style="margin:3px;"> Last >|</a>',
            btn_first_page_html: '<a href="javascript:;" style="margin:3px;"><| First</a>',
            loader: true,
            loader_text: "Filtering data..."
        };

        var tf1 = setFilterGrid("tblOrder", tf1_Props);

        $(".openDialog2").click(function (e) {
            e.preventDefault();

            $("<div></div>")
                    .addClass("dialog")
                    .attr("id", $(this)
                    .attr("data-dialog-id"))
                    .appendTo("body")
                    .dialog({
                        title: $(this).attr("data-dialog-title"),
                        close: function () { $(this).remove(); },
                        modal: true,
                        height: 800,
                        width: 1200,
                        left: 0

                    })
                    .load(this.href);
        });

        $(".close").click(function (e) {
            e.preventDefault();
            $(this).closest(".dialog").dialog("close");
        });
    });
</script>

<section>
    @using (Html.BeginForm("BackToMainMeun", "Home"))
    {
        <br align="center" />
        <input type="submit" value="Back To Main Menu" />
    }
</section>